<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        if(true){
            var num = 10;//声明变量,var声明的是全局变量
           // let num = 10;//let声明的是局部变量
            num = num * 2;
            document.write(num);
        }

        document.write("<hr/>");
        document.write(num);//使用代码块中声明的变量

    </script>
</body>
</html>